import java.io.File;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class XMLPARSER {

    /**
     * @param args
     */
    public static void main(String[] args) {
	try {
	    DocumentBuilderFactory factory = DocumentBuilderFactory
		    .newInstance();
	    DocumentBuilder builder = factory.newDocumentBuilder();

	    File f = new File("C:\\2.xml");
	    Document doc = builder.parse(f);

	    Element root = doc.getDocumentElement();

	    NodeList children = root.getChildNodes();
	    for (int i = 0; i < children.getLength(); i++) {
		Node child = children.item(i);

		NodeList childNodes = child.getChildNodes();
		
		if (childNodes.getLength() > 1 && childNodes != null) {
		    
		    for (int x = 0; x <childNodes.getLength(); x++) {

		       System.out.println(childNodes.item(x).getNodeName());
		    }
		}
	    }

	} catch (Exception ex) {
	    ex.printStackTrace();
	}
    }

}
